﻿using System;
using System.Diagnostics;
using System.Windows;

namespace FinalPointSet.View.Dialog
{
    /// <summary>
    /// MessageDialog.xaml 的交互逻辑
    /// </summary>
    public partial class MessageDialog : Window
    {

        private string _Title = "MessageDialog";
        /// <summary>
        /// 标题
        /// </summary>
        public new string Title
        {
            get { return _Title; }
            set { tbTitle.Text = value; _Title = value; }
        }

        private string _Content = string.Empty;
        /// <summary>
        /// 内容
        /// </summary>
        public new string Content
        {
            get { return _Content; }
            set { tbContent.Text = value; _Content = value; }
        }
        public MessageDialog()
        {
            InitializeComponent();
        }
        public MessageDialog(string title, string content)
        {
            InitializeComponent();
            Title = title;
            Content = content;
        }
        private void OnExitButtonClick(object sender, RoutedEventArgs e)
        {
            CloseDialog(false);
        }

        private void OnOKButtonClick(object sender, RoutedEventArgs e)
        {
            CloseDialog(true);
        }
        private void CloseDialog(bool dialogResult)
        {
            try
            {
                DialogResult = dialogResult;
            }
            catch (Exception ex)
            {
                Debug.Print($"MessageDialog.CloseDialog({dialogResult}), 对话框以窗体的形式出现");
                Debug.Print($"Exception, Message={ex.Message}, Data={ex.Data}");

            }
            Close();
        }

        /// <summary>
        /// 弹出对话框
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="content">内容</param>
        /// <returns></returns>
        public static bool? Pop(string title = "", string content = "")
        {
            return new MessageDialog(title, content).ShowDialog();
        }
    }
}
